#
# Handles checking user input on matrices
#
# 2009, Mike Widner <mikewidner@gmail.com>
#
##########

package Fangcheng::CGI::UserInput;

use 5.006001;
use strict;
use warnings;
use Carp;
use Fangcheng::Calc::Determinants;
use vars qw(@ISA);

require Fangcheng::CGI;

@ISA = qw( Fangcheng::CGI );

my $VERSION = '0.01';

sub new {
	my ($class) = shift;
	return( bless {}, ref($class) || $class );
}

# go through a matrix and zero out all fields that can't have values other than 0
# for the determinantal solution
sub formDeterminantMatrix {
	my ($self, $matrix) = @_;
	my $calc = Fangcheng::Calc::Determinants->new();
	
	for my $row ( 1 .. $matrix->rows ) {
		for my $col ( 1 .. $matrix->columns ) {
			next if ( $calc->canSetField( $matrix, $row, $col ) == 1 );
			$matrix->set( $row, $col, 0 );
		}
	}
	
	return( $matrix );
}

1;